home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / games / larn12s.arc / LARN.ARC / OBJECT.C < prev    next >
C/C++ Source or Header  |  1987-10-28  |  27KB  |  845 lines

  1. /*    object.c        Larn is copyrighted 1986 by Noah Morgan. */
  2. #include "header.h"
  3.  
  4. /*
  5.     ***************
  6.     LOOK_FOR_OBJECT
  7.     ***************
  8.  
  9.     subroutine to look for an object and give the player his options
  10.     if an object was found.
  11.  */
  12. lookforobject()
  13. {
  14. register int i,j;
  15. if (c[TIMESTOP])  return;    /* can't find objects is time is stopped    */
  16. i=item[playerx][playery];    if (i==0) return;
  17. showcell(playerx,playery);  cursors();  yrepcount=0;
  18. switch(i)
  19.     {
  20.     case OGOLDPILE:    case OMAXGOLD:
  21.     case OKGOLD:    case ODGOLD:    lprcat("\n\nYou have found some gold!");    ogold(i);    break;
  22.  
  23.     case OPOTION:    lprcat("\n\nYou have found a magic potion");
  24.                 i = iarg[playerx][playery];
  25.                 if (potionname[i][0]) lprintf(" of %s",&potionname[i][1]);  opotion(i);  break;
  26.  
  27.     case OSCROLL:    lprcat("\n\nYou have found a magic scroll");
  28.                 i = iarg[playerx][playery];
  29.                 if (scrollname[i][0])    lprintf(" of %s",&scrollname[i][1]);
  30.                 oscroll(i);  break;
  31.  
  32.     case OALTAR:    if (nearbymonst()) return;
  33.                     lprcat("\n\nThere is a Holy Altar here!"); oaltar(); break;
  34.  
  35.     case OBOOK:    lprcat("\n\nYou have found a book."); obook(); break;
  36.  
  37.     case OCOOKIE:    lprcat("\n\nYou have found a fortune cookie."); ocookie(); break;
  38.  
  39.     case OTHRONE:    if (nearbymonst()) return;
  40.                     lprintf("\n\nThere is %s here!",objectname[i]); othrone(0); break;
  41.  
  42.     case OTHRONE2:    if (nearbymonst()) return;
  43.                     lprintf("\n\nThere is %s here!",objectname[i]); othrone(1); break;
  44.  
  45.     case ODEADTHRONE: lprintf("\n\nThere is %s here!",objectname[i]); odeadthrone(); break;
  46.  
  47.     case OORB:        lprcat("\n\nYou have found the Orb!!!!!"); oorb(); break;
  48.  
  49.     case OPIT:        lprcat("\n\nYou're standing at the top of a pit."); opit(); break;
  50.  
  51.     case OSTAIRSUP:        lprcat("\n\nThere is a circular staircase here"); ostairs(1);  /* up */ break;
  52.  
  53.     case OELEVATORUP:    lprcat("\n\nYou feel heavy for a moment, but the feeling disappears");
  54.                 oelevator(1);  /*  up  */  break;
  55.  
  56.     case OFOUNTAIN:    if (nearbymonst()) return;
  57.                     lprcat("\n\nThere is a fountain here"); ofountain(); break;
  58.  
  59.     case OSTATUE:    if (nearbymonst()) return;
  60.                     lprcat("\n\nYou are standing in front of a statue"); ostatue(); break;
  61.  
  62.     case OCHEST:    lprcat("\n\nThere is a chest here");  ochest();  break;
  63.  
  64.     case OIVTELETRAP:    if (rnd(11)<6) return;
  65.                         item[playerx][playery] = OTELEPORTER;
  66. # ifdef DGK
  67.                         know[playerx][playery] = KNOWALL;
  68. # else
  69.                         know[playerx][playery] = 1;
  70. # endif
  71.  
  72.     case OTELEPORTER:    lprcat("\nZaaaappp!  You've been teleported!\n");
  73.                         beep(); nap(3000); oteleport(0);
  74.                         break; 
  75.  
  76.     case OSCHOOL:    if (nearbymonst()) return;
  77.                 lprcat("\n\nYou have found the College of Larn.");
  78.                 lprcat("\nDo you (g) go inside, or (i) stay here? ");
  79.                 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
  80.                 if (i == 'g') { oschool();  /*    the college of larn    */ }
  81.                 else    lprcat(" stay here");
  82.                 break;
  83.  
  84.     case OMIRROR:    if (nearbymonst()) return;
  85.                     lprcat("\n\nThere is a mirror here");    omirror();    break;
  86.  
  87.     case OBANK2:
  88.     case OBANK:    if (nearbymonst()) return;
  89.                 if (i==OBANK) lprcat("\n\nYou have found the bank of Larn.");
  90.                 else lprcat("\n\nYou have found a branch office of the bank of Larn.");
  91.                 lprcat("\nDo you (g) go inside, or (i) stay here? ");
  92.                 j=0; while ((j!='g') && (j!='i') && (j!='\33')) j=getchar();
  93.                 if (j == 'g') {  if (i==OBANK) obank(); else obank2(); /*  the bank of larn  */  }
  94.                 else   lprcat(" stay here");
  95.                 break;
  96.  
  97.     case ODEADFOUNTAIN:    if (nearbymonst()) return;
  98.                         lprcat("\n\nThere is a dead fountain here"); break;
  99.  
  100.     case ODNDSTORE:    if (nearbymonst()) return;
  101.                     lprcat("\n\nThere is a DND store here.");
  102.                     lprcat("\nDo you (g) go inside, or (i) stay here? ");
  103.                     i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
  104.                     if (i == 'g')
  105.                         dndstore();  /*  the dnd adventurers store  */
  106.                     else  lprcat(" stay here");
  107.                     break;
  108.  
  109.     case OSTAIRSDOWN:    lprcat("\n\nThere is a circular staircase here"); ostairs(-1); /* down */ break;
  110.  
  111.     case OELEVATORDOWN:    lprcat("\n\nYou feel light for a moment, but the feeling disappears");
  112.                 oelevator(-1);    /*    down    */
  113.                 break;
  114.  
  115.     case OOPENDOOR:        lprintf("\n\nYou have found %s",objectname[i]);
  116.                         lprcat("\nDo you (c) close it"); iopts();
  117.                         i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
  118.                         if ((i=='\33') || (i=='i')) { ignore();  break; }
  119.                         lprcat("close");  forget();
  120.                         item[playerx][playery]=OCLOSEDDOOR;
  121.                         iarg[playerx][playery]=0;
  122.                         playerx = lastpx;  playery = lastpy;
  123.                         break;
  124.  
  125.     case OCLOSEDDOOR:    lprintf("\n\nYou have found %s",objectname[i]);
  126.                         lprcat("\nDo you (o) try to open it"); iopts();
  127.                         i=0; while ((i!='o') && (i!='i') && (i!='\33')) i=getchar();
  128.                         if ((i=='\33') || (i=='i'))
  129.                             { ignore();  playerx = lastpx;
  130.                             playery = lastpy; break; }
  131.                         else
  132.                         {
  133.                         lprcat("open");
  134.                         if (rnd(11)<7)
  135.                           {
  136.                           switch(iarg[playerx][playery])
  137.                             {
  138.                             case 6: c[AGGRAVATE] += rnd(400);    break;
  139.  
  140.                             case 7:    lprcat("\nYou are jolted by an electric shock "); 
  141.                                     lastnum=274; losehp(rnd(20));  bottomline();  break;
  142.  
  143.                             case 8:    loselevel();  break;
  144.  
  145.                             case 9:    lprcat("\nYou suddenly feel weaker ");
  146.                                     if (c[STRENGTH]>3) c[STRENGTH]--;
  147.                                     bottomline();  break;
  148.  
  149.                             default:    break;
  150.                             }
  151.                           playerx = lastpx;  playery = lastpy;
  152.                           }
  153.                         else
  154.                           {
  155.                           forget();  item[playerx][playery]=OOPENDOOR;
  156.                           }
  157.                         }
  158.                         break;
  159.  
  160.     case OENTRANCE:    lprcat("\nYou have found "); lprcat(objectname[OENTRANCE]);
  161.                     lprcat("\nDo you (g) go inside"); iopts();
  162.                     i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
  163.                     if (i == 'g')
  164.                         {
  165.                         newcavelevel(1); playerx=33; playery=MAXY-2;
  166.                         item[33][MAXY-1]=know[33][MAXY-1]=mitem[33][MAXY-1]=0;
  167.                         draws(0,MAXX,0,MAXY); bot_linex(); return;
  168.                         }
  169.                     else   ignore();
  170.                     break;
  171.  
  172.     case OVOLDOWN:    lprcat("\nYou have found "); lprcat(objectname[OVOLDOWN]);
  173.                         lprcat("\nDo you (c) climb down"); iopts();
  174.                         i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
  175.                         if ((i=='\33') || (i=='i')) { ignore();  break; }
  176.                     if (level!=0) { lprcat("\nThe shaft only extends 5 feet downward!"); return; }
  177.                     if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep();
  178.                                               lastnum=275;  losehp(30+rnd(20)); bottomhp(); }
  179.                     
  180.                     else lprcat("climb down");  nap(3000);  newcavelevel(MAXLEVEL);
  181.                     for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++) /* put player near volcano shaft */
  182.                         if (item[j][i]==OVOLUP) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); }
  183.                     draws(0,MAXX,0,MAXY); bot_linex(); return;
  184.  
  185.     case OVOLUP:    lprcat("\nYou have found "); lprcat(objectname[OVOLUP]);
  186.                         lprcat("\nDo you (c) climb up"); iopts();
  187.                         i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
  188.                         if ((i=='\33') || (i=='i')) { ignore();  break; }
  189.                     if (level!=11) { lprcat("\nThe shaft only extends 8 feet upwards before you find a blockage!"); return; }
  190.                     if (packweight() > 45+5*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep();
  191.                                               lastnum=275; losehp(15+rnd(20)); bottomhp(); return; }
  192.                     lprcat("climb up"); lflush(); nap(3000); newcavelevel(0);
  193.                     for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++) /* put player near volcano shaft */
  194.                         if (item[j][i]==OVOLDOWN) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); }
  195.                     draws(0,MAXX,0,MAXY); bot_linex(); return;
  196.  
  197.     case OTRAPARROWIV:    if (rnd(17)<13) return;    /* for an arrow trap */
  198.                         item[playerx][playery] = OTRAPARROW;
  199.                         know[playerx][playery] = 0;
  200.  
  201.     case OTRAPARROW:    lprcat("\nYou are hit by an arrow"); beep();    /* for an arrow trap */
  202.                         lastnum=259;    losehp(rnd(10)+level);
  203.                         bottomhp();    return;
  204.  
  205.     case OIVDARTRAP:    if (rnd(17)<13) return;        /* for a dart trap */
  206.                         item[playerx][playery] = ODARTRAP;
  207.                         know[playerx][playery] = 0;
  208.  
  209.     case ODARTRAP:        lprcat("\nYou are hit by a dart"); beep();    /* for a dart trap */
  210.                         las